package cn.fz.event.describe;

import cn.fz.entity.User;
import cn.fz.event.publish.LoginApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

/**
 * ⑤ 通过实现ApplicationListener接口，实现登录通知消息的消费，并做相关的业务处理
 */
@Service
public class LoginNotifyListen implements ApplicationListener<LoginApplicationEvent> {

    public void accumulateLogin(User user) {
        System.out.println("=======登录业务======" + user);
    }

    @Override
    public void onApplicationEvent(LoginApplicationEvent event) {
        System.out.println("===============收到登录通知事件===================");
        User user = (User) event.getSource();
        accumulateLogin(user);
    }
}
